import React from 'react';
import { Modal, message } from 'antd';
import { Org, deleteOrg } from '@/service/unit/org';

const Groups: React.FC<{
  show: boolean;
  onCancel: (e?: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
  onOk: (e?: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
  currentData: Org;
}> = ({ show, onCancel, onOk, currentData }) => {
  return (
    <Modal
      title="删除"
      open={show}
      onOk={async () => {
        const res = await deleteOrg(currentData.id);
        if (res.success) {
          onOk();
          message.success('删除成功');
        } else {
          message.error(res.details || res.message);
        }
      }}
      onCancel={onCancel}
    >
      {`是否删除: ${currentData.org_name} ?`}
    </Modal>
  );
};
export default Groups;
